package com.mages.dataService.controller;

import com.mages.dataService.REST.DataServiceRESTTemplate;
import com.mages.dataService.service.*;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class dataServiceController {

    @RequestMapping(value="/dataService",method = {RequestMethod.GET,RequestMethod.POST})
    public DataServiceRESTTemplate dataService(@RequestParam("requestUUID") String requestUUID,
                                               @RequestParam("dataName") String dataName,
                                               @RequestParam("clientHostName") String clientHostName,
                                               @RequestParam("clientRequestIP") String clientRequestIP,
                                               @RequestParam("req_timestamp") long req_timestamp,
                                               @RequestParam("dataServiceTime") long dataServiceTime,
                                               @RequestParam("dataflag") int dataflag){
        DataService service = new DataService(requestUUID, dataName, clientHostName, clientRequestIP,req_timestamp,dataServiceTime,dataflag);
        return service.RunDataService();
    }

    @RequestMapping(value="/dataService/logs",method = {RequestMethod.GET,RequestMethod.POST})
    public List<String> Logs_service(){
        LogsService logsService = new LogsService();
        return logsService.ReadLogs();
    }

    @RequestMapping(value="/dataService/concurrency",method = {RequestMethod.GET,RequestMethod.POST})
    public Integer Cocurrency_service(){
        ConcurrencyService concurrencyService = new ConcurrencyService();
        return concurrencyService.QueryConcurrency();
    }

    @GetMapping("/dataService/test")
    public String test(){
        return "ok";}
}
